package com.youlu.campus.admin.home;


import com.youlu.campus.admin.auth.common.DeviceType;
import com.youlu.campus.admin.auth.shiro.token.AuthToken;
import com.youlu.campus.admin.auth.shiro.token.AuthType;
import org.apache.shiro.SecurityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


/**
 * Created by zhuhuaiqi
 */
@RestController
public class HomeController {

    protected final Logger logger = LoggerFactory.getLogger(this.getClass());
    @PostMapping("/login")
    public String loginForm(@RequestParam(value = "domain") String domain, @RequestParam(value = "username") String username,
                            @RequestParam(value = "password") String password) {
//        org.apache.shiro.subject.Subject subject = SecurityUtils.getSubject();
//        AuthToken token = new AuthToken(username, password, domain, false, "localhost", AuthType.USERNAME_PASSWORD,
//                DeviceType.WEB);
//        token.setComId("5fc5e0c6b8016b1f865aa02f");
//        token.setDomain(domain);
//        token.setUid(username);
//        token.setUsername(username);
//        token.setAuthType(AuthType.USERNAME_PASSWORD);
//        token.setPassword(password.toCharArray());
//        subject.login(token);
        return "login";
    }

    @RequestMapping("/index")
    public String index() {
        return "/index";
    }

    @RequestMapping("/unauthorized")
    public String unauthorize() {
        return "unauthorized";
    }
}
